package com.edu.base.ums.memberShareRecord.controller;

import com.edu.base.ums.memberShareRecord.domain.ClsMemberShareRecord;
import com.edu.base.ums.memberShareRecord.service.IClsMemberShareRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会员邀请码分享记录Controller
 * 
 * @author zw
 * @date 2022-06-27
 */
@RestController
@RequestMapping("/memberShareRecord/memberShareRecord")
public class ClsMemberShareRecordController extends BaseController
{
    @Autowired
    private IClsMemberShareRecordService clsMemberShareRecordService;

    /**
     * 查询会员邀请码分享记录列表
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClsMemberShareRecord clsMemberShareRecord)
    {
        startPage();
        List<ClsMemberShareRecord> list = clsMemberShareRecordService.selectClsMemberShareRecordList(clsMemberShareRecord);
        return getDataTable(list);
    }

    /**
     * 导出会员邀请码分享记录列表
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:export')")
    @Log(title = "会员邀请码分享记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ClsMemberShareRecord clsMemberShareRecord)
    {
        List<ClsMemberShareRecord> list = clsMemberShareRecordService.selectClsMemberShareRecordList(clsMemberShareRecord);
        ExcelUtil<ClsMemberShareRecord> util = new ExcelUtil<ClsMemberShareRecord>(ClsMemberShareRecord.class);
        return util.exportExcel(list, "memberShareRecord");
    }

    /**
     * 获取会员邀请码分享记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(clsMemberShareRecordService.selectClsMemberShareRecordById(id));
    }

    /**
     * 新增会员邀请码分享记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:add')")
    @Log(title = "会员邀请码分享记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClsMemberShareRecord clsMemberShareRecord)
    {
        return toAjax(clsMemberShareRecordService.insertClsMemberShareRecord(clsMemberShareRecord));
    }

    /**
     * 修改会员邀请码分享记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:edit')")
    @Log(title = "会员邀请码分享记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClsMemberShareRecord clsMemberShareRecord)
    {
        return toAjax(clsMemberShareRecordService.updateClsMemberShareRecord(clsMemberShareRecord));
    }

    /**
     * 删除会员邀请码分享记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareRecord:memberShareRecord:remove')")
    @Log(title = "会员邀请码分享记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(clsMemberShareRecordService.deleteClsMemberShareRecordByIds(ids));
    }
}
